# if not utility.has_collection(DOC_COLLECTION_NAME):
from pymilvus import (
    connections,
    FieldSchema,
    DataType,
    CollectionSchema,
    Collection,
    utility,
)
import random

connections.connect(
    "default", host="192.168.1.62", port="19530", db_name="zhangrenyang"
)
collection_name = "blog"
try:
    collection = Collection(collection_name)
    # 生成随机数据
    # vectors = [123,456]
    # data = [[123,456],[789,110]]
    # 把数据插入到集合中，并获取插入的结果
    # mr = collection.insert(data)

    data = [
        {"embedding": [random.random() for _ in range(128)]},
        {
            "embedding": [random.random() for _ in range(128)],
        },
    ]
    mr = collection.insert(data)
    print("插入向量数据:", mr.insert_count)
except Exception as e:
    print(e)

# [[[0.1, 0.2, 0.3], [0.4, 0.5, 0.6]], [[0.7, 0.8, 0.9], [0.10, 0.11, 0.12]]]
